<template>
	<view class="main">
		<view class="time" @click="go">
			{{time==0?'':time}}<text>跳过</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				time: 3
			}
		},
		onLoad() {
			this.dateTime()
		},
		methods:{
			go(){
				this.time = 0
			},
			dateTime(){
				let timer = setInterval(() => {
					if (this.time > 0) {
						this.time--;
					} else {
						clearInterval(timer);
						uni.getStorage({
							key: 'userInfo',
							success: function(res) {
								//console.log('userInfo---------', res)
								if (!res.data.token) {
									uni.redirectTo({
										url: '/pages/Login/index'
									});
						
								} else {
									uni.switchTab({
									    url: '/pages/Index/index'
									});
								}
							},
							fail: function(err) {
								//console.log('userInfo---------', err)
								uni.redirectTo({
									url: '/pages/Login/index'
								});
							}
						});
					}
				}, 1000)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		width: 100vw;
		height: 100vh;
		background: url(../../static/720.png)center/cover no-repeat;

		.time {
			width: 130rpx;
			height: 60rpx;
			color: #FFFFFF;
			border-radius: 20rpx;
			background-color: rgba(255, 255, 255, 0.2);
			text-align: center;
			line-height: 60rpx;
			font-size: 14px;
			position: fixed;
			right: 20rpx;
			top: 80rpx;
			text{
				margin-left: 10rpx;
			}
		}
	}
</style>
